package com.itheima.zuoye.zuoye3;

import java.util.Map;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        TreeMap<Lao, Name> map = new TreeMap<>();
        map.put(new Lao("张三", 18), new Name("北京"));
        map.put(new Lao("李四", 20), new Name("上海"));
        map.put(new Lao("王五", 35), new Name("天津"));
        map.put(new Lao("赵六", 21), new Name("北京"));
        map.put(new Lao("田七", 19), new Name("上海"));
        //按照年龄排序从大到小

        //删除张三的信息
        map.remove(new Lao("张三", 18));
        //修改李四的地址为郑州
        map.put(new Lao("李四", 20), new Name("郑州"));
        //输出结果
        map.forEach((k,v)-> System.out.println(k+"--->"+v));
        System.out.println("===========");
        map.entrySet().
                stream().forEach(e-> System.out.println(e.getKey().getAge()+"岁的"+e.getKey().getName()+"--"+e.getValue().getName()));





    }
}
